package com.jackrain.nea.fc.cp.mapper;

import com.alibaba.fastjson.JSONObject;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.jdbc.SQL;
import java.util.HashMap;
/**
 * Created by ZCY on 2017/12/14.
 */
@Mapper
public interface CadorgMapper {

    class Cadorgupcl {

        public String adorgaupdate(JSONObject jo) {
            return new SQL() {
                {
                    UPDATE("CP_C_ADORG ");
                    for (String key : jo.keySet()) {
                        if (!"ID".equals(key)) {
                            SET(key + "=" + "#{" + key + "}");
                        }
                    }
                    WHERE("ID = #{ID}");
                }
            }.toString();
        }
    }


    @UpdateProvider(type = CadorgMapper.Cadorgupcl.class, method = "adorgaupdate")
    int cpadorgupdate(JSONObject jsonObject);


    @Select("select ENAME from CP_C_HRORG where ID=#{id}")
    HashMap findhorgname(Long id);


    @Select("select `NAME` as cn, ENAME as `displayName`,`PASSWORD` as `unicodePwd`,CP_C_HRORG_ID,ISENABLED,CP_C_STORE_ID from USERS where ID=#{id}   and ADYU='Y'")
    HashMap findUsers(Long id);

    @Select("SELECT CP_C_ORGUP_ID,ENAME,TREENO,ISACTIVE  from CP_C_HRORG where ID=#{id}")
    HashMap findorgin(Long id);

//    @Select("select `NAME` as cn,ENAME as `displayName`,`PASSWORD` as `unicodePwd`,CP_C_HRORG_ID,WECHAT as weixin,email as `mail`,mobil as `mobile`,CP_C_EMP_ID,ISENABLED  from USERS where ID=#{id}")
//    JSONObject findhuseratu(Long id);

    @Select("select `NAME` as cn,`SEX` as sex,ENAME as `displayName`,`PASSWORD` as `unicodePwd`,CP_C_HRORG_ID,WECHAT as weixin,email as `mail`,mobil as `mobile`,CP_C_EMP_ID,ISENABLED,CP_C_STORE_ID from USERS where ID=#{id}   and ADYU='Y'")
    JSONObject findhuseratu(Long id);

    @Select("select STORENATURE  from CP_C_STORE where ID=#{id}")
    String findstorenature(Long id);


    @Select("select ENAME,CP_C_HRORG_ID,ISACTIVE  from CP_C_STORE where ID=#{id}")
    HashMap findstore(Long id);

    @Select("select EMP_POST from cp_c_emp where ID=#{id}")
    HashMap findjobename(Long id);

    @Select("select ENAME as `displayName`,`SEX` as sex,WECHAT as weixin,email as `mail`,mobil as `mobile`,CP_C_EMP_ID from USERS where ID=#{id}  and ADYU='Y'")
    JSONObject findusersel(Long id);


}
